home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / raylabwos / docs / raylab.doc < prev    next >
Encoding:
Text File  |  1998-11-08  |  78.3 KB  |  2,193 lines

  1.  
  2.  
  3.                                 R a y L a b
  4.  
  5.                                    v1.1
  6.  
  7.                       (c)1995-1996 by Marcus Geelnard
  8.  
  9.                             Users Documentation
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                              TABLE OF CONTENTS
  16.                              =================
  17.  
  18.     1.0 INTRODUCTION
  19.  
  20.         1.1  Background
  21.  
  22.         1.2  What does RayLab do?
  23.  
  24.     2.0 FEATURES   
  25.  
  26.         2.1  Primitives
  27.  
  28.         2.2  Textures
  29.  
  30.         2.3  Transforms
  31.  
  32.         2.4  Constructive Solid Geometry (CSG)
  33.  
  34.         2.5  Anti-aliasing
  35.  
  36.         2.6  Display
  37.  
  38.     3.0 HOW TO CREATE 3D IMAGES WITH RAYLAB
  39.  
  40.         3.1  An example scene
  41.  
  42.         3.2  Invoking RayLab
  43.  
  44.     4.0 LANGUAGE REFERENCE
  45.  
  46.         4.1  General
  47.  
  48.         4.2  Primitives
  49.             4.2.1  Sphere
  50.             4.2.2  Ellipsoid
  51.             4.2.3  Plane
  52.             4.2.4  Box
  53.             4.2.5  Triangle
  54.             4.2.6  Trianglelist
  55.             4.2.7  Disc
  56.             4.2.8  Cylinder
  57.             4.2.9  Cone
  58.  
  59.         4.3  Constructive Solid Geometry (CSG)
  60.             4.3.1  CSG Operators
  61.                 4.3.1.1  And
  62.                 4.3.1.2  Or
  63.                 4.3.1.3  Minus
  64.                 4.3.1.4  Plus
  65.             4.3.2  Inverting an object
  66.  
  67.         4.4  Textures
  68.             4.4.1  Color
  69.             4.4.2  Colormap
  70.             4.4.3  Pattern
  71.                 4.4.3.1  checker
  72.                 4.4.3.2  circles
  73.                 4.4.3.3  rings
  74.                 4.4.3.4  spots
  75.                 4.4.3.5  gradient
  76.                 4.4.3.6  squares
  77.                 4.4.3.7  marble
  78.                 4.4.3.8  softmarble
  79.                 4.4.3.9  blurb
  80.                 4.4.3.10 mandel
  81.                 4.4.3.11 wood
  82.                 4.4.3.12 angular
  83.                 4.4.3.13 none
  84.             4.4.4  Reflect
  85.             4.4.5  Diffuse
  86.             4.4.6  Ambient
  87.             4.4.7  Phong
  88.             4.4.8  Phongsize
  89.             4.4.9  Filter
  90.             4.4.10  Ior
  91.             4.4.11  Image
  92.                 4.4.11.1  iff
  93.                 4.4.11.2  tga
  94.                 4.4.11.3  ppm
  95.                 4.4.11.4  maptype
  96.                     4.4.11.4.1  planar
  97.                     4.4.11.4.2  spherical
  98.                     4.4.11.4.3  cylindrical
  99.                 4.4.11.5  tile and notile
  100.                 4.4.11.6  interpolate and nointerpolate
  101.             4.4.12 Turbulence
  102.             4.4.13 Default
  103.  
  104.         4.5  Deftexture
  105.  
  106.         4.6  Transform
  107.             4.6.1  Scale
  108.             4.6.2  Move
  109.             4.6.3  Rotate
  110.             4.6.4  Whirl
  111.             4.6.5  Twist
  112.             4.6.6  None
  113.  
  114.         4.7  Deftransform
  115.  
  116.         4.8  Bounding volumes
  117.             4.8.1  How to use bounding volumes in RayLab
  118.             4.8.2  When to use bounding volumes
  119.  
  120.         4.9  Miscellaneous object modifers
  121.             4.9.1  Noshadow and shadow
  122.  
  123.         4.10 Lights
  124.             4.10.1 Location
  125.             4.10.2 Color
  126.             4.10.3 Soft light-sources
  127.                 4.10.3.1 size
  128.                 4.10.3.2 softness
  129.                 4.10.3.3 jitter
  130.  
  131.         4.11  Camera
  132.             4.11.1  Location
  133.             4.11.2  Viewpoint
  134.             4.11.3  Aspect
  135.  
  136.         4.12  Globals
  137.             4.12.1  Picwidth
  138.             4.12.2  Picheight
  139.             4.12.3  Format
  140.             4.12.4  Recdepth
  141.             4.12.5  Display
  142.             4.12.6  Antialiasrec
  143.             4.12.7  Antialiasthreshold
  144.             4.12.8  Antialiastjitter
  145.             4.12.9  Quickscan
  146.             4.12.10 Trace
  147.             4.12.11 Backgroundcolor
  148.             4.12.12 Fogdistance
  149.             4.12.13 Fogcolor
  150.  
  151.         4.13  Comments
  152.  
  153.     5.0 MISCELLANEOUS
  154.  
  155.         5.1  How to contact the author
  156.  
  157.         5.2  Legal stuff
  158.  
  159.         5.3  Past, present and the future
  160.  
  161.         5.4  Acknowledgements
  162.  
  163.         5.5  Compability
  164.  
  165.         5.6  Comments by the author
  166.  
  167.  
  168.  
  169.  
  170.                              1.  INTRODUCTION
  171.                              ================
  172.  
  173.  
  174.  
  175. 1.1 Background
  176. --------------
  177.  
  178. My intention with RayLab was, first of all, to create a decent raytracer
  179. based on my newfound (rather limited) knowledge in linear algebra, as I
  180. took a course in that particular subject at the university.  I also wanted
  181. to improve my skills in C-programming (this is my third 'real' C program).
  182. As it turned out it was not hard at all to create a working program, and
  183. after about a week of programming I could already produce good looking
  184. pictures with shades, reflections, highlights, texture-patterns and several
  185. different shape primitives.  A working (but primitive) description language
  186. had also been introduced successfully at that time.
  187.  
  188. After being convinced that it was possible to create a usable raytracer, I
  189. wanted to use it as a base for introducing features that I miss in other
  190. raytracers, not having to think about rendering times; with fast computers
  191. at the university I can sacrifice time to get a good looking image.  In
  192. short, RayLab was, for me, a personal 'hack'.
  193.  
  194. As time went on, more and more people contacted me from all over the world,
  195. telling me about how they liked RayLab and feeding me with ideas about how
  196. to improve RayLab.  Jean-Baptiste Novoit in France helped me out with
  197. documentation and compilation.  Brian Jones in Canada chose RayLab as his
  198. favourite raytracer and helped me a lot with beta-testing.  Amith Yamsani
  199. at Cornell University used RayLab as a base for a project in parallell
  200. computing.  Just to name a few.  Also, the amount of visitors to the RayLab
  201. home page on the WWW has increased drastically since the release of RayLab
  202. 1.0 rev 1.  All of this moral support has triggered me to really try to
  203. make something great out of RayLab, which means, among other things, that
  204. it will be faster and easier to use (things that came in second hand in my
  205. old plan for RayLab).
  206.  
  207. One thing still remains though, and that is that RayLab is totally free of
  208. cost!  I have always felt that free software is good software, and I hope
  209. that I will never have to get paid for programming RayLab; it is an act of
  210. creation, not greed.
  211.  
  212.  
  213.  
  214. 1.2 What does RayLab do?
  215. ------------------------
  216.  
  217. RayLab is capable of producing realistic three-dimensional images using a
  218. technique called 'ray-tracing'.  What this basically means is that you
  219. place 3D objects in a space (room, world, scene or whatever you like to
  220. call it).  Then you add some light-sources and a camera.  What the
  221. raytracer does is to mathematically calculate what the picture would look
  222. like, if it was to be taken by a real camera.
  223.  
  224. To get technical, this is done by dividing the picture into small elements
  225. (pixels) and for each element, a ray (or beam) is cast, from the camera out
  226. into the three-dimensional space.  If this ray 'hits' an object, some steps
  227. are taken:
  228.  
  229.   1) The color of the object is checked.
  230.  
  231.   2) The light from different light-sources are checked, and also another
  232.      ray (from the point on the object to the light-source(s)) is cast to
  233.      see if any other objects block the light. This way shadows are produ-
  234.      ced.
  235.  
  236.   3) If the object is reflective, a new ray will be cast to see if any
  237.      other objects are visible thorugh reflection of the first object.
  238.  
  239.   4) If the object is transparent, a new ray will be produced which contin-
  240.      ues on the other side of the surface of the object.
  241.  
  242. The information from all these calculations is used to set the color of the
  243. pixel in the picture.  This procedure is repeated for every ray, including
  244. all 'camera-rays' and those produced by reflection and transparency.  As
  245. you would probably guess, this requires a great deal of computation.  On a
  246. normal personal computer calcualtion times of several hours are not too
  247. uncommon (a processor with good floating point performance is strongly
  248. recommended).
  249.  
  250.  
  251.  
  252.  
  253.                                2.  FEATURES
  254.                                ============
  255.  
  256. RayLab is a program that will probably be updated with new features every
  257. now and then, as I like experimenting with new effects.  Some of the major
  258. features of the current version of RayLab are mentioned in this section.
  259.  
  260.  
  261.  
  262. 2.1  Primitives
  263. ---------------
  264.  
  265. Primitives are the basic shapes that make the building blocks of objects.
  266. Some raytracers are specialized at only handling objects built up from
  267. triangles (just as a 2D object can be built up from lines, a 3D object can
  268. be described by triangles, but only roughly), but RayLab handles several
  269. different shapes.  Those are (at the moment):  sphere, ellipsoid, plane
  270. (infinitly long and wide), box, triangle, disc, cylinder and cone.
  271.  
  272.  
  273.  
  274. 2.2  Textures
  275. -------------
  276.  
  277. The shape of an object is not enough to describe it.  The surface of an
  278. object is very significant for its appearance.  For instance, a polished
  279. wooden table looks completely different than a transparent glass-table.  In
  280. RayLab a surface texture means a set of properties that describe the looks
  281. and feels of a surface.  The different properties are:  color (or set of
  282. color-transitions), pattern, diffuse reflection (color intensity
  283. proportional to surrounding light-sources), highlight intensity and
  284. concentration, ambient light, reflection, transparency with refraction and
  285. finally turbulence (for distorting patterns).  It is also possible to map
  286. an image onto an object, which further extends the possibilities to
  287. customize the appearance of an object.
  288.  
  289.  
  290.  
  291. 2.3  Transforms
  292. ---------------
  293.  
  294. In general, primitives and textures in RayLab have a basic orientaion in
  295. space.  Therefore, you may need to transform a shape and/or texture into
  296. what you need for your specific needs.  For instance, the box primitive is
  297. always aligned along the x-y-z-axes, which is not always convenient when
  298. you want to construct complex scenes.  This is where the transformation
  299. facilities of RayLab come in handy.  All primitives can be transformed in
  300. any of the following ways (or a complex combination of these):  scaling,
  301. movement (displacement) and rotation.  This is also valid for all textures.
  302. Be warned though:  transformation can consume much computation power,
  303. especially rotation of primitives, so do not use it unless you need it (or
  304. have a monster computer).  There are some special transformations that can
  305. be done to textures, but not to objects, namely whirl and twist.
  306.  
  307.  
  308.  
  309. 2.4  Constructive Solid Geometry (CSG)
  310. --------------------------------------
  311.  
  312. When neither the basic primitives nor transformation of these are enough to
  313. produce the shapes that you want, constructive solid geometry (CSG) can do
  314. magic.  The idea is to combine two or more primitives with logical
  315. operations to produce a new shape.  The operations that are needed (and
  316. supported by RayLab) are:  AND, OR, MINUS and PLUS (the latter is not
  317. really necessary though).  With AND, the intersection of two shapes is
  318. produced.  With OR, you get a union of two objects.  With MINUS, you can
  319. cut out a piece of an object with another object.  The PLUS operator acts
  320. like the OR operator, but it is faster and not suitable for transparent
  321. objects nor objects that are used in other "CSG's".  The exact workins of
  322. each operator is described in chapter 4.  Note that throughout this
  323. documentation, 'CSG' written by itself often refers to a combination of
  324. objects with the constructive solid geometry facilities of RayLab (i.e. a
  325. CSG section).
  326.  
  327.  
  328.  
  329. 2.5  Anti-aliasing
  330. ------------------
  331.  
  332. When you render a picture with a computer program such as RayLab, chances
  333. are that the picture will look very 'jaggy'.  This is because the pixels on
  334. the computer screen are square, and often visible to the eye.  With
  335. anti-aliasing this rough look can be eliminated.  The idea is to use
  336. several rays per pixel, and calculate the average color found by these
  337. rays.  This method gives a very smooth and realistic appearance, but it
  338. also consumes more computation power.  Anti-aliasing should be used for
  339. final output pictures, as it is quite unnecessary during the process of
  340. creating a scene.
  341.  
  342.  
  343.  
  344. 2.6  Display
  345. ------------
  346.  
  347. One useful feature of RayLab is that it can display the output picture to
  348. your screen while rendering it.  This is good for displaying previews.
  349. Currently only the Amiga and the OS/2 versions of RayLab have support for
  350. graphical displays, but I hope for more persons to develop display routines
  351. for different platforms, or to improve the available routines.
  352.  
  353.  
  354.  
  355.  
  356.                   3.  HOW TO CREATE 3D IMAGES WITH RAYLAB
  357.                   =======================================
  358.  
  359. To have RayLab create a picture for you, you first have to describe the
  360. picture to it.  This is done by setting up a 'scene', which can be created
  361. in any text-editor or word-processor that can save raw ascii files (Amiga:
  362. ed, bed, ced, PC:  edit, Unix:  vi, emacs, nedit...  etc.).  The
  363. description is made in a special language, which is described in detail in
  364. chapter 4.  In the scene you will need to have at least one object and one
  365. light-source.  You will probably want to set up a camera as well.
  366.  
  367.  
  368.  
  369. 3.1  An example scene
  370. ---------------------
  371.  
  372. To get to know a program or programming language, it is always wise to look
  373. at demonstration examples.  So to get things started, here is an example of
  374. a complete scene description (detailed explanations will follow).  This
  375. scene can also be found in the scenes directory of the RayLab distribution,
  376. named 'demo1.rl':
  377.  
  378.  
  379. ---------------------------------------------------------------------------
  380.  
  381. Globals:
  382.         picwidth 320            # Image dimensions: 320x240
  383.         picheight 240
  384.         backgroundcolor 0 0 0   # Red=0, green=0, blue=0 => black
  385. :end
  386.  
  387. Sphere:
  388.         centre  0 0 2           # Place the sphere in x=0, y=0, z=2
  389.         radius  2               # ...and it will have a radius of 2 units
  390. :end
  391.  
  392. Light:
  393.         location 3 -8 4         # A light-source at x=3, y=-8, z=4
  394.         color    1 1 1          # Red=1.0, green=1.0, blue=1.0 => white
  395. :end
  396.  
  397. Camera:
  398.         location -1 -9 2        # Place the camera in x=-1, y=-9, z=2
  399.         viewpoint 0 0 2         # Look at x=0, y=0, z=2
  400. :end
  401.  
  402. ---------------------------------------------------------------------------
  403.  
  404.  
  405. On the first line, the keyword 'Globals:' is found.  This means that the
  406. next section will contain some information that is global to the whole
  407. scene.  This section is ended by the keyword ':end' on line five.  On the
  408. second line the picture width is declared by 'picwidth 320'.  Next follows
  409. a comment, which is started by a '#' and ended by the end of the line.  On
  410. the next line the picture height is declared.  The fourth line says
  411. 'backgroundcolor 0 0 0', which means that the background color should be
  412. black.  All colors in RayLab are described by their red, green and blue
  413. components, in that order, each component ranging from 0.0 (min) to 1.0
  414. (max).
  415.  
  416. The next section describes a primitive.  This primitive is a sphere with
  417. its centre in (0,0,2), and the radius 2.  All points and vectors in RayLab
  418. are described by their x, y and z components, and are aligned to a right-
  419. hand system.  This means that the x-axis points right, the y-axis away and
  420. the z-axis points upwards.  The sphere is not given a texture, so it will
  421. use the default texture.  The default texture is, if none else given, a
  422. non-reflective dull red surface.
  423.  
  424. The third section describes a light-source, which is located at (3,-8,4)
  425. and has the color white (all three components are set to their maximum
  426. value 1.0).  The light-source casts its light all the way to the infinity
  427. in all directions.
  428.  
  429. Last, but not least, a camera is set up.  The parameters location and
  430. viewpoint sort of speak for themselves.
  431.  
  432. To finally render (compute) the picture which is described by this scene,
  433. you just have to call RayLab from your shell (cli, dos, or whatever).  To
  434. render the example above, type:
  435.  
  436.         raylab  -iscenes/demo1.rl -opics/demo1.iff
  437.  
  438. That will produce an iff picture named 'demo1.iff' in the directory 'pics'.
  439.  
  440.  
  441.  
  442. 3.2  Invoking RayLab
  443. --------------------
  444.  
  445. RayLab is started from shell.  When invoking RayLab you may pass several
  446. control parameters.  The general syntax is:
  447.  
  448.         raylab <parameters>
  449.  
  450. Parameters are, in general, given as a flag with an argument attached to
  451. it.  For instance, you specify the width of the output image to 320 pixels
  452. with -w320.  Note that no space is allowed between the flag (in this case
  453. -w) and the argument (320).
  454.  
  455. The currently supported parameters are (the order in which they are entered
  456. on the command line is of no significance):
  457.  
  458.  
  459.   Parameter:                      Specifies:
  460. ---------------------------------------------------------------------------
  461.   -i<input scene-description>     The input scene (required)
  462.   -o<output image>                The output image file (required *)
  463.   -f<image format>                File format, which may be:
  464.                                    iff  (24 bit compressed IFF (ILBM))
  465.                                    tga  (24 bit uncompressed Targa)
  466.                                    ppm  (24 bit PPM)
  467.                                    none (No output file at all)
  468.   -w<width>                       Width of the output image (columns)
  469.   -h<height>                      Height of the output image (rows)
  470.   -d<display-type>                Display type (platform-specific)
  471.   -r<trace recursion-depth>       Maximum recursion depth for trace
  472.   -ar<anti-alias recursion-depth> Anti alias recursion depth
  473.   -at<anti-alias threshold>       Anti alias threshold
  474.   -aj<anti-alias jitter>          Anti alias jitter
  475.   -q                              Perform quick-scan (preview)
  476.   -t                              Perform full-featured trace (default)
  477.   -l                              List all available display-modes, then
  478.                                   exit RayLab (do nothing)
  479.  
  480.  (*) An output file has to be specified, unless the image format is set to
  481.      'none'.
  482.  
  483.  
  484. For more information about what each parameter means, and what their
  485. default values are, please consult section 4.12 (globals).
  486.  
  487. Here is an example for rendering a scene described in 'myscenes/test.rl' to
  488. an iff image called 'pics/test.iff':
  489.  
  490.     raylab -imyscenes/test.rl -opics/test.iff -fiff -d1 -w640 -h480 -ar2
  491.  
  492. This means: input file = 'myscenes/test.rl', output file = 'pics/test.iff',
  493. format = iff, display type = 1, image width = 640, image-height = 480,
  494. and anti-aliasing recursion depth = 2.
  495.  
  496. To interrupt RayLab while it is generating an image, press ctrl+c.  This
  497. should work on most systems.  If the output format is iff or tga, the
  498. output image will be correctly truncated to contain only the lines that
  499. were generated before the break.  If you for instance start rendering a
  500. 320x240 image, and press ctrl+c when RayLab has come to line 100, the
  501. output image will be truncated to 320x99.  So far, this feature is not
  502. implemented for ppm output.
  503.  
  504.  
  505.  
  506.  
  507.                           4.  LANGUAGE REFERENCE
  508.                           ======================
  509.  
  510.  
  511. 4.1  General
  512. ------------
  513.  
  514. The description language that RayLab uses is very simple, which may be a
  515. benefit or a drawback, depending on your personal needs.  I have tried to
  516. make the interpreter as flexible as possible though to leave the layout to
  517. the user.  This has been accomplished by the following means:
  518.  
  519.    o  Keywords can be entered in (almost) any order (*).
  520.    o  RayLab is totally case insensitive (SpHeRe: is the same thing as 
  521.       SPHERE:).
  522.    o  RayLab does not differ between spaces, tabs and line-feeds (except
  523.       when you use comments), so indents, line-spaces etc. does not make a
  524.       difference to RayLab; e.g. you can write several keywords on one line.
  525.    o  In many cases you can leave some keywords out. This will result in
  526.       that RayLab will use default settings for those keywords that are not 
  527.       specified.
  528.  
  529.   (*) The shape specific keywords in object declarations must be entered
  530.       before general object keywords.
  531.  
  532. A description is built up from several "sections", each section beginning
  533. with a keyword with a terminating colon (e.g.  Box:), and ending with :end.
  534. Sections may also have sub-sections.  For instance a primitive may have a
  535. texture specification, which is also a section.
  536.  
  537. RayLab uses a right-hand system for the space-coordinates, which means:
  538. the x-axis points right, the y-axis points away (into the screen) and the
  539. z-axis points up.  All coordinates and vectors are given by three decimal
  540. numbers.  For instance, -2 0.5 1.5 means x=-2, y=0.5 and z=1.5.  In RayLab,
  541. much is based on unit-sizes, which means that you should keep your
  542. coordinates and sizes somewhere around the 1.0 - 10.0 range for comfort
  543. (but of course, you may scale textures etc to fit a sphere with the radius
  544. 1000, if you prefer those dimensions).
  545.  
  546. Colors are described with three decimal numbers, like coordinates, but the
  547. numbers represent the red, green and blue components of the color.  Each
  548. number must be in the range 0.0 - 1.0, where 0.0 means 0%, and 1.0 means
  549. 100%.  So, the statement 'color 0.0 1.0 0.5' means 0% red, 100% green and
  550. 50% blue, which makes a light green color with a blue touch.
  551.  
  552.  
  553.  
  554. 4.2  Primitives
  555. ---------------
  556.  
  557. As mentioned before, the so called primitvies are the actual shapes that
  558. you will use to build your scene.  Each primitive is declared by creating a
  559. section that describes the primitive.  The section must begin with the data
  560. that is specific to the primitive that is declared (e.g.  radius, corners,
  561. centre etc.), unless you choose to leave that information out to use the
  562. default values.  After that, general descriptions may be entered, such as
  563. texture, transformation, bounding volume etc.
  564.  
  565.  
  566.  
  567. 4.2.1  Sphere
  568.  
  569. The sphere primitive is a classic round shape, which is defined by its
  570. location in space (centre) and its radius.  Example:
  571.  
  572. Sphere:
  573.         centre 0 0 3
  574.         radius 2
  575. :end
  576.  
  577. The default sphere has the radius 1.0 and has its centre at (0,0,0).
  578.  
  579.  
  580.  
  581. 4.2.2  Ellipsoid
  582.  
  583. The ellipsoid is a more or less redundant shape, as it can be produced from
  584. a scaled sphere, but it was the first primitive introduced in RayLab and as
  585. such is kept due to nostalgic reasons.  Unlike the sphere, the ellipsoid
  586. needs three values to describe the radius, one for each axis.  Example:
  587.  
  588. Ellipsoid:
  589.         centre 0 0 3
  590.         radius 2 1.5 4
  591. :end
  592.  
  593. The default ellipsoid has the radius (1,1,1) and is located at (0,0,0).
  594.  
  595.  
  596.  
  597. 4.2.3  Plane
  598.  
  599. A plane is an infinitely long and wide, totally flat surface.  It is
  600. defined by its surface normal, which is orthogonal to the surface, and its
  601. offset along this normal.  This example shows a plane which could be
  602. described as all points (x,y,z) which has x=-1 (regardless of y and z):
  603.  
  604. Plane:
  605.         normal 1 0 0
  606.         offset -1
  607. :end
  608.  
  609. The default plane has the surface normal (0,0,1) and offset 0.0, i.e. it
  610. stretches along the x and y axes.
  611.  
  612.  
  613.  
  614. 4.2.4  Box
  615.  
  616. The box is simply a polyhedron with six sides, like a dice.  It is describ-
  617. ed by two points in space (its corners).  For instance, a cube with its
  618. eight courners:
  619.  
  620.   (0,0,0), (2,0,0), (2,2,0), (0,2,0), (0,0,2), (2,0,2), (2,2,2), (0,2,2)
  621.  
  622. would look like this described to RayLab:
  623.  
  624. Box:
  625.         corners 0 0 0
  626.                 2 2 2
  627. :end
  628.  
  629. Thus each side of the box is always parallel to two of the axes.  To
  630. create a box with any alignment, you can simply transform it.
  631.  
  632. The default box is a unit cube with the corners (0,0,0), (1,1,1).
  633.  
  634.  
  635.  
  636. 4.2.5  Triangle
  637.  
  638. A triangle is defined by its three corners in space. Example:
  639.  
  640. Triangle:
  641.         corners 0 0 -1
  642.                 3 -2 4
  643.                 -5 -1 3
  644. :end
  645.  
  646. The default triangle has the corners (0,0,0), (1,1,1), (-1,1,1).
  647.  
  648.  
  649.  
  650. 4.2.6  Trianglelist
  651.  
  652. A trianglelist is a list of several triangles.  The advantages of a
  653. trianglelist over several separate triangles are obvious for large
  654. triangle-objects.  Trianglelists consume less memory, as it only needs one
  655. texture and one transformation for all triangles, as compared to one for
  656. each triangle.  Trianglelists occupy less space in the description-file,
  657. and trianglelists are faster.  The trianglelist is used just like the
  658. triangle, with the one difference that you may enter more than one
  659. corner-description.  Example:
  660.  
  661. Trianglelist:
  662.         corners 0 0 0     1 0 0     1 0 1
  663.         corners 0 0 0     0 1 1     1 0 1
  664.         ...
  665.         ...
  666. :end
  667.  
  668. The default trianglelist has one triangle with the corners (0,0,0),
  669. (1,1,1), (-1,1,1).
  670.  
  671.  
  672.  
  673. 4.2.7  Disc
  674.  
  675. The disc is an infinitely thin surface, just like the plane.  The diff-
  676. erence between the plane and the disc, is that the disc has a radius,
  677. whereas the plane is infinitely long and wide.  Thus the disc looks like a
  678. disc (he-he).  The definition of a disc requires three parameters:  centre,
  679. normal and radius.  Example:
  680.  
  681. Disc:
  682.         centre 2 -3 2
  683.         normal 1 -2 1
  684.         radius 1.5
  685. :end
  686.  
  687. The default disc has the following settings:
  688.         centre:  (0,0,0)
  689.         normal:  (0,0,1)
  690.         radius:  1
  691.  
  692.  
  693.  
  694. 4.2.8  Cylinder
  695.  
  696. The cylinder is defined by its radius and its two end positions in space
  697. (for compability with RayLab 1.0, you can also specify it with its height,
  698. and thus leaving the end positions out).  The ends are specified with the
  699. keywords start and end.  The cylinder is "closed" by two discs, one at each
  700. end (all in the spirit of solid geometry).  This example demonstrates a
  701. cylinder that lies along the x-axis, with its ends in (-3,0,0) and (3,0,0):
  702.  
  703. Cylinder:
  704.         radius 1.4
  705.         start -3 0 0
  706.         end 3 0 0
  707. :end
  708.  
  709. The default cylinder has a radius of 1.0, start (0,0,0), and end (0,0,1).
  710.  
  711.  
  712.  
  713. 4.2.9  Cone
  714.  
  715. The cone is similar to the cylinder, with the one difference that you
  716. specify one radius for each end of the cone.  Thus the cone needs its two
  717. end positions in space and its two radii.  The ends are specified with the
  718. keywords start and end.  The two radii are specified with the keyword
  719. radius, followed by start <start-radius> end <end-radius>.  The cone, like
  720. the cylinder, is "closed" by two discs, one at each end.  Here is an
  721. example of a cone:
  722.  
  723. Cone:
  724.         start 0 0 0
  725.         end 3 -2 1
  726.         radius start 1.5 end 0.5
  727. :end
  728.  
  729. The default cone starts in (0,0,0), ends in (0,0,1), has the start-radius
  730. 1.0 and end-radius 0.0.
  731.  
  732.  
  733.  
  734. 4.3  Constructive Solid Geometry (CSG)
  735. --------------------------------------
  736.  
  737. A very powerful feature of RayLab is the ability to combine several objects
  738. into a new shape.  You may perform logical operations with two or more
  739. shapes.  To declare such a combination to RayLab, use the following syntax:
  740.  
  741. Csg:
  742.         <shape>:                # First shape in CSG section
  743.                 ...
  744.                 ...
  745.         :end
  746.  
  747.         <operator>
  748.  
  749.         <shape>:                # Second shape in CSG section
  750.                 ...
  751.                 ...
  752.         :end
  753.  
  754.         <operator>
  755.         ...
  756.         ...
  757.         <operator>
  758.  
  759.         <shape>:                # N:th shape in CSG section
  760.                 ...
  761.                 ...
  762.         :end
  763. :end
  764.  
  765. In a CSG section you must specify at least two shapes, but there is no
  766. limit to how many you can have in each section.  The operator may be one of
  767. the following:  AND, OR, MINUS or PLUS.  In a single CSG section, all
  768. operators must be of the same kind (you may not mix different operators).
  769. One exception to this rule, is that AND and MINUS are treated equally.
  770. Actually, MINUS is an AND operand, but the second object is inverted, which
  771. means that the inside becomes the outside, and vice versa.
  772.  
  773. The shapes in a CSG section are described with normal object declarations,
  774. with or without object modifiers, such as texture and transformation.
  775. Texture declarations must be defined within the individual shape declar-
  776. ations (or with a deftexture statement before the CSG section), but
  777. transformations can be placed at the end of a CSG section, thus
  778. transforming all objects contained in the section.
  779.  
  780. The shapes that may be part of a CSG section must be such that they have a
  781. clear inside and outside.  Currently they are:  plane, sphere, ellipsoid,
  782. box, cylinder, cone, and even another CSG section.  The inside and outside
  783. of these objects are very easy to determine (the "outside" of a plane is
  784. the "upside", which is where the surface normal points, and the "inside" is
  785. the opposite side).  Shapes that may not be part of a CSG section are the
  786. triangle, the trianglelist and the disc (they do not have an inside nor
  787. an outside).
  788.  
  789.  
  790.  
  791. 4.3.1  CSG Operators
  792.  
  793. As mentioned before, the logical operators that RayLab supports are AND,
  794. OR, MINUS and PLUS.  Here you get an explanation of each operator.  Note
  795. that although I have chosen to describe the situation where only two
  796. objects are used in a CSG-combination, several objects can be combined in
  797. the same manner.
  798.  
  799.  
  800. 4.3.1.1  And
  801.  
  802. If you combine two objects with the and operator, a new body is produced
  803. which consists of all points in space that are inside both the first and
  804. the second object.  Points that are inside one of the objects, but not the
  805. other, are not part of the new body.
  806.  
  807.  
  808. 4.3.1.2  Or
  809.  
  810. If you combine two objects with the or operator, a new body is produced
  811. which consists of all points in space that are inside either the first or
  812. the second object, or inside both objects.  Surfaces from either of the two
  813. objects that are inside the new body are removed, which looks better for
  814. transparent objects, and it works better if you want to use the new body in
  815. another CSG section.
  816.  
  817.  
  818. 4.3.1.3  Minus
  819.  
  820. With the minus operator you can cut out a piece of an object with another
  821. object.  The first object is the object that is being 'cut' by the second
  822. object.  If more than two objects are used in a minus-combination, the
  823. first object is the'original', and all the following objects (the second,
  824. the third etc...) are 'cutting' objects.
  825.  
  826.  
  827. 4.3.1.4  Plus
  828.  
  829. The plus-operator acts similarly to the or-operator.  To combine several
  830. objects in a plus-CSG is an easy way to group several objects into a single
  831. object, and it is faster than to use the or-operator.  Be warned though:
  832. if you use the plus-operator, the inner surfaces will not be removed, thus
  833. making transparent objects look 'funny', and if you use a CSG with
  834. plus-operators with another CSG, you may not get the results that you
  835. expect.
  836.  
  837.  
  838.  
  839. 4.3.2  Inverting an object
  840.  
  841. By adding the keyword invert to an object declaration, the inside of the
  842. object becomes the outside, and vice versa.  If you, for instance, invert
  843. an object that is part of a CSG, where the operator is AND, you achieve the
  844. same effect as with MINUS, where the inverted object is the removal-object.
  845. The invert keyword also affects transparency, if the surface refracts
  846. light, as 'going into the object' is replaced by 'going out of the object',
  847. and vice versa.  If you would like to produce air-bubbles in water, for
  848. instance, you could use inverted transparent spheres as bubbles.
  849.  
  850.  
  851.  
  852. 4.4  Textures
  853. -------------
  854.  
  855. RayLab provides many facilities to make the surface texture of an object
  856. realistic.  To add or change a texture of a primitive, add a texture-
  857. section to the primitive declaration.  Example:
  858.  
  859. Plane:
  860.         normal 0 0 1
  861.         offset -2
  862.         texture:
  863.                 color 0.5 0.4 0.8
  864.                 reflect 0.5 0.4 0.5
  865.                 phong 0.6
  866.         :end
  867. :end
  868.  
  869. In the following sections all supported texture keywords are described.
  870.  
  871.  
  872.  
  873. 4.4.1  Color
  874.  
  875. All primitives have their own color, which can be specified by the keyword
  876. color.  Following the keyword there should be three decimal values
  877. specifying the red, green and blue components of the color (in that order).
  878. The values can range from 0.0 (0%) to 1.0 (100%).
  879.  
  880. The default color is 1.0 0.3 0.0, which is 100% red + 30% green.
  881.  
  882.  
  883.  
  884. 4.4.2  Colormap
  885.  
  886. When you want to give an object surface a pattern (e.g.  the rings of a
  887. piece of wood), it is not satisfying to only have one color for the object.
  888. Normally you want to have a set of colors, and smooth transitions between
  889. those colors.  This is acomplished with a colormap.  A colormap sort of
  890. creates a spectrum with different colors, just like the sky can have nice
  891. transitions between red and blue and maybe some other colors when the sun
  892. sets.  A colormap can consist of a maximum of ten entries.  Each entry is
  893. given a color, and a place in the map, which is a value between 0.0 and
  894. 1.0.  When you declare a colormap, you also have to give the amount of
  895. entries with an integer value following the keyword colormap.  Here is an
  896. example of a colormap with the colors of the rainbow:
  897.  
  898.     colormap 7                  # This colormap contains seven entries
  899.         0.0   0.4 0.0 0.7       # The first entry (at 0.0) has the color
  900.         0.3   0.0 0.0 0.9       #  0.4 0 0.7
  901.         0.4   0.0 0.4 1.0
  902.         0.6   0.0 1.0 0.0
  903.         0.75  1.0 1.0 0.0
  904.         0.9   1.0 0.0 0.0
  905.         1.0   0.4 0.0 0.0       # The last entry (at 1.0) has the color
  906.                                 #  0.4 0 0
  907.  
  908. Note:  All entries must be entered in ascending order with 0.0 first and
  909. 1.0 last.
  910.  
  911. Actually, when a color is specified with the color keyword, a colormap with
  912. two entries is created; the first entry is 0.0, with the color which is
  913. specified after the color keyword, and the second entry is 1.0, with the
  914. color black.  This is done so that a pattern will be visible even if only
  915. one color is specified.  This means that the default colormap has two
  916. entries:  the first is red and the second is black.
  917.  
  918.  
  919.  
  920. 4.4.3  Pattern
  921.  
  922. Patterns can significantly improve the appearance of an object.  RayLab
  923. gives you a variety of patterns to chose from, and more are sure to come.
  924. A pattern will assign a value to each point of the object.  This value
  925. ranges from 0.0 to 1.0 and is used as index to the colormap of the object
  926. (see section 4.4.2).  What follows is a description of the currently
  927. available patterns in RayLab.  Experiment with them on different shapes to
  928. get to know how they work!
  929.  
  930.  
  931. 4.4.3.1  checker
  932.  
  933. Now this is a pattern we all want!  A raytracer is not worth the name
  934. without this pattern.  The checker pattern is simply an infinite amount of
  935. 1x1x1 cubes in 3D space.  If applied to a plane it will look just like a
  936. chess-board, but if you apply it to a sphere it can look rather strange
  937. (try it, and you will see exactly how it works!).  Each cube can have one
  938. of two colors, and the color is chosen from the colormap of the object.
  939. The first color is picked from the colormap with index 0.0, and the second
  940. will be picked from index 1.0.  Here is an example of a blue and green
  941. checkered texture:
  942.  
  943.     texture:
  944.         pattern checker
  945.         colormap 2
  946.                 0  0 0 1        # index = 0.0, color = 0.0 0.0 1.0
  947.                 1  0 1 0        # index = 1.0, color = 0.0 1.0 0.0
  948.     :end
  949.  
  950.  
  951. 4.4.3.2  circles
  952.  
  953. Circles are like onion-rings.  The colormap index is simply proportional to
  954. the distance from (0,0,0).  Within one unit-distance from (0,0,0) the
  955. index-value changes from 0.0 to 1.0, then it goes straight back to 0.0, and
  956. increaces to 1.0 at two units, and then it starts over again...
  957.  
  958.  
  959. 4.4.3.3  rings
  960.  
  961. The rings pattern works like circles, but it only depends on the x-y
  962. coordinates.  This means that it extends along the z-axis.
  963.  
  964.  
  965. 4.4.3.4  spots
  966.  
  967. The spots pattern will simply produce spots on the surface of an object.
  968. The spots are three-dimensional.  The centre of the spot will get the color
  969. from the colormap at 0.0.  The further away from the centre of the spot,
  970. the larger the colormap index.  At the edge of the spot, and outside of the
  971. spot, the colormap index is 1.0.
  972.  
  973.  
  974. 4.4.3.5  gradient
  975.  
  976. Gradient is probably the simplest pattern possible.  The colormap index
  977. changes with the z-axis.  It increases from 0.0 to 1.0 within one unit
  978. along the z-axis, then it starts over from 0.0 again...
  979.  
  980.  
  981. 4.4.3.6  squares
  982.  
  983. The squares pattern works much like the spots pattern (not like the checker
  984. pattern).  At the centre of each square, the colormap index is 0.0, and at
  985. the edge the color-map index is 1.0.  The index smoothly changes from 0.0
  986. to 1.0 within the square.  Just like the spots pattern, the squares are
  987. three-dimensional.
  988.  
  989.  
  990. 4.4.3.7  marble
  991.  
  992. Marble is a very good looking texture to use on stone-like floors, tables
  993. etc.  If the marble pattern is applied to an object 'as-is', it will only
  994. produce an infinite amount of distorted lines (which are parallel to the yz
  995. plane).  To make it look good, you would typically have to add some
  996. turbulence to the texture, and maybe rotate and/or scale it too.
  997.  
  998.  
  999. 4.4.3.8  softmarble
  1000.  
  1001. Softmarble is nearly identical to marble, but it has a smoother look.
  1002. Again, try experimenting...
  1003.  
  1004.  
  1005. 4.4.3.9  blurb
  1006.  
  1007. For a surface texture that is more or less stocastic (such as different
  1008. kinds of stone), the blurb pattern is very useful.  It simply uses a solid
  1009. noise function to produce a colormap index.  Solid noise in RayLab means
  1010. that two points that are close to each other have values that are close,
  1011. and two points that are far away from each other have values that may
  1012. differ greatly.  The blurb pattern needs some turbulence to give it life,
  1013. else it may look a bit 'stiff'.
  1014.  
  1015.  
  1016. 4.4.3.10 mandel
  1017.  
  1018. Long before I made RayLab, I made a program that generated three-
  1019. dimensionally projected fractal-images, such as the mandelbrot set.  As it
  1020. is very easy to implement, I added the mandelbrot fractal as a texture
  1021. pattern for RayLab too (called mandel).  It uses the xy plane as the
  1022. complex plane (x is the real axis, and y is the imaginary axis).  The
  1023. fractal image looks identical regardless of the position on the z-axis.  In
  1024. the current implementation a maximum of 100 iterations are performed.  For
  1025. you who do not know how a mandelbrot fractal looks (you must have seen it
  1026. somewhere), try rendering the example scene 'scenes/mandel.rl'.
  1027.  
  1028.  
  1029. 4.4.3.11  wood
  1030.  
  1031. The wood pattern is very much like the rings pattern, but it contains a
  1032. small variation of the ring-radius, which depends on the position on the
  1033. circle (the angle from the x-axis) and the position along the z-axis.  Try
  1034. a small rotation around the x or y axis, and perhaps a small turbulence
  1035. aswell.  It is not easy to make wood look realistic, but experiment a bit,
  1036. and it may turn out lovely.
  1037.  
  1038.  
  1039. 4.4.3.12  angular
  1040.  
  1041. The angular pattern uses the angle from the positive x-axis in the xy-plane
  1042. for the colormap index (it sweeps around the z-axis).  Very simple indeed,
  1043. but useful sometimes.
  1044.  
  1045.  
  1046. 4.4.3.13  none
  1047.  
  1048. Specifying a pattern with the identifier none will give the object a
  1049. monocolored surface.  The color will be picked from the colormap with
  1050. index 0.0.
  1051.  
  1052. The default pattern is none.
  1053.  
  1054.  
  1055.  
  1056. 4.4.4  Reflect
  1057.  
  1058. Reflection is one of the most interesting and powerful featurs of the
  1059. raytracing technique compared to other forms of 3D rendering.  In RayLab
  1060. you can choose how much light an object should reflect (with the keyword
  1061. reflect).  You can also decide what colors will be reflected.  Here is an
  1062. example of a reflection that reflects 70% of all light:
  1063.  
  1064.     reflect  0.7 0.7 0.7           # red=70%, green=70%, blue=70%
  1065.  
  1066. The default reflection is no reflection at all (0 0 0).
  1067.  
  1068.  
  1069.  
  1070. 4.4.5  Diffuse
  1071.  
  1072. The diffuse keyword specifies how much of the light from the surrounding
  1073. light-sources will affect the color intensity of the object.  The diffuse
  1074. intensity is specified by a decimal value ranging from 0.0 to 1.0 (0% to
  1075. 100%).  If a value of zero is given, the object will have the same color
  1076. intensity on its lightened side as on its shadowed side.  Normally, you
  1077. would want a value between 0.5 and 1.0.
  1078.  
  1079. The default diffuse intensity is 0.8 (80%).
  1080.  
  1081.  
  1082.  
  1083. 4.4.6  Ambient
  1084.  
  1085. If you look around in "the real world", you will see that even in dark
  1086. shadows, objects are visible.  This is due to the diffuse reflection from
  1087. other surrounding objects.  In a normal raytracer like RayLab, this is a
  1088. very difficult and power consuming task to produce.  Instead this is
  1089. simulated by the ambient effect, which will give the object a default
  1090. light-intensity on every point of the surface.  The ambient effect can also
  1091. be used to create "glowing" objects.  However, the ambient of one object
  1092. will not affect any other objects.  The keyword ambient is followed by a
  1093. decimal value ranging from 0.0 to 1.0 (0% ambient to 100%).
  1094.  
  1095. The default ambient is 0.2 (20%).
  1096.  
  1097.  
  1098.  
  1099. 4.4.7  Phong
  1100.  
  1101. The phong keyword specifies how intense highlights from light-sources
  1102. should be.  Phong highlights have the same color as the light-source that
  1103. it is produced from, and is not proportional to the object color at all (a
  1104. black object will have the same highlight color and intensity as a green
  1105. object, if their phong-values are the same).
  1106.  
  1107. The default phong value is 0.3 (30%).
  1108.  
  1109.  
  1110.  
  1111. 4.4.8  Phongsize
  1112.  
  1113. With phongsize you can specify the tightness of the phong highlight.  The
  1114. keyword is followed by a positive decimal value.  Higher values give
  1115. tighter spots.  Theoretically the phongsize value can range from zero to
  1116. infinity, but in practice you would typically want a value larger than
  1117. 1.0 (at least) and smaller than 100.
  1118.  
  1119. The default phongsize is 10.0.
  1120.  
  1121.  
  1122.  
  1123. 4.4.9  Filter
  1124.  
  1125. With the keyword filter you tell RayLab how transparent an object should
  1126. be, and also what colors it should 'let through'.  After the keyword you
  1127. must specify three decimal values, representing the amount of red, green
  1128. and blue light the surface of the object should filter through.  If all
  1129. three components are set to 1.0, the object would be perfectly transparent.
  1130. If all components are set to 0.0, no light will come through the surface of
  1131. the object.
  1132.  
  1133. The default filter is (0.0 0.0 0.0), which means 0% transparency.
  1134.  
  1135.  
  1136.  
  1137. 4.4.10  Ior
  1138.  
  1139. Most transparent objects refract light.  This is because the light has
  1140. different speeds in different media; the thicker the media, the slower the
  1141. speed of light.  To tell RayLab how much an object should refract light,
  1142. you specify the index of refraction, ior.  This index is 1.0 or more, where
  1143. 1.0 represents air or vaccum.  Typical values are:  water - 1.3, glass -
  1144. 1.5, and diamond - 2.5.  A phenomenon which may occur when light exits a
  1145. thick medium, is that it bounces back if the angle between the light-ray
  1146. and the surface is too small.  This is called total internal reflection,
  1147. and it is handled automatically by RayLab.
  1148.  
  1149. The default ior is 1.0, which means no refraction.
  1150.  
  1151.  
  1152.  
  1153. 4.4.11  Image
  1154.  
  1155. If the built in patterns of RayLab are not enough, you may experiment with
  1156. mapping images onto your objects.  You may choose from three different
  1157. maptypes at the moment:  planar, spherical and cylindrical.  Three
  1158. image-formats are supported:  IFF (1-8 bit colormapped and 24-bit true
  1159. color), Targa (24-bit true color) and PPM (24-bit true-color, P6-format).
  1160.  
  1161. Specifying a texture image is done by adding an image section to your
  1162. texture section, like this, for example:
  1163.  
  1164.     texture:
  1165.         ...
  1166.         image:
  1167.                 iff textures/myface.iff
  1168.                 ...
  1169.         :end
  1170.         ...
  1171.     :end
  1172.  
  1173. The image may be transformed by adding a transform section to the image
  1174. section.  If the texture is transformed, the image too will be transformed.
  1175.  
  1176. In the image section, you may enter some additional information about how
  1177. the image will be treated.
  1178.  
  1179. 4.4.11.1  iff
  1180.  
  1181. If your image is stored as an iff file, you specify its name after the
  1182. keyword iff.  Note that you may not enclose the file-name within brackets,
  1183. and the file-name may not contain any spaces.  File-names are case-
  1184. sensitive, if your operating system is.  RayLab currently handles 24-bit
  1185. iff files (IFF24), as well as 1-8 bit (2-256 colors) color-mapped images.
  1186. It does not, however, handle HAM6, HAM8, EHB, 12-, 15- or 16-bit images.
  1187.  
  1188. 4.4.11.2  tga
  1189.  
  1190. If your image is stored as a tga file, you specify its name after the
  1191. keyword tga.  The file-name is treated in the same way as for iff files.
  1192. RayLab currently only handles uncompressed 24-bit tga files (which is the
  1193. most common format anyway).
  1194.  
  1195. 4.4.11.3  ppm
  1196.  
  1197. As I added PPM output support, I figured it might be a good idea to support
  1198. PPM input as well.  As I do not know very much about the PPM format, it may
  1199. be that RayLab does not handle your pictures.  The currently supported
  1200. format is the P6 format, which holds uncompressed 24-bit binary data.
  1201.  
  1202. 4.4.11.4  maptype
  1203.  
  1204. Depending on the shape of the object you want to use your image on, you may
  1205. want to use different types of mappings.  That is, how to place the image
  1206. in 3D space.  As a normal image is two-dimensional, it is not clear how it
  1207. should be placed in the three-dimensional space that RayLab deals with.
  1208. With the keyword maptype, you may specify which method you want to use.
  1209. After the keyword, you enter one of these three keywords:  planar,
  1210. spherical or cylindrical.  This part may make you a bit dizzy (at least I
  1211. got dizzy writing it), so I recommend that you experiment on your own to
  1212. find out how the different maptypes work.
  1213.  
  1214. The default maptype is planar.
  1215.  
  1216. 4.4.11.4.1  planar
  1217.  
  1218. The most common method is to use planar mapping, which means that you
  1219. simply 'throw away' one axis.  In the case of RayLab, it is the z-axis that
  1220. is being lost, and the x and y axes are used as the coordinates in the 2D
  1221. image.  Regardless of the original image size, it will always be placed so
  1222. that the lower left corner lies in (x,y)=(0,0), and the upper right corner
  1223. lies in (x,y)=(1,1).  As the z-axis is not used, the image will be
  1224. 'stretched' along the z-axis.  To make the image fit your object properly,
  1225. you may need to transform the texture (you can not transform the image
  1226. individually).  By default, the image will be 'tiled' when you use planar
  1227. mapping, which means that the image is repeated over the entire xy-plane.
  1228.  
  1229. 4.4.11.4.2  spherical
  1230.  
  1231. The spherical mapping is useful for spheres.  It acts radically differently
  1232. from planar mapping, in that it uses two angles as the x and y coordinates.
  1233. The simplest way to understand how spherical mapping works, is to think of
  1234. your image as a flat map of the world and your object (the sphere) being
  1235. the earth-globe.  To get the countries, oceans and polar ices in the right
  1236. place, you would have to 'wrap' the map around the globe (which is
  1237. physically impossible, but in theory everything can be done!).  That is
  1238. exactly what RayLab does whith your image and your sphere.  As a result of
  1239. this method, there will only be one copy of your image on your object, and
  1240. you should also try to use an image which is twice as wide as it is high,
  1241. if you want to retain the original image proportions.  RayLab assumes that
  1242. the object is located in (0,0,0) in space.  Otherwise you will have to
  1243. transform the texture to make it fit your object.
  1244.  
  1245. 4.4.11.4.3  cylindrical
  1246.  
  1247. You could say that the cylindrical mapping is a combination of spherical
  1248. mapping and planar mapping.  When you use cylindrical mapping, RayLab
  1249. assumes that you have a cylinder that stretches along the z-axis.  The
  1250. image will be wrapped one turn around the z-axis, and be drawn one time
  1251. from z=0.0 to z=1.0.  By default the image will repeat at z=1.0 to z=2.0
  1252. and so on.
  1253.  
  1254.  
  1255. 4.4.11.5  tile and notile
  1256.  
  1257. With the keywords tile and notile you can control whether or not the image
  1258. should be repeated outside of its origin (e.g.  (x,y)=(0,0) to (x,y)=(1,1)
  1259. for planar mapping).  If you choose notile, the color/colormap/pattern
  1260. settings will be used outside of the image.  The keywords have no effect on
  1261. spherical mapping.
  1262.  
  1263. The default is to tile the image.
  1264.  
  1265.  
  1266. 4.4.11.6  interpolate and nointerpolate
  1267.  
  1268. The keyword interpolate tells RayLab to use a simple linear method for
  1269. interpolating the color-values 'inbetween' the pixels of your image.  The
  1270. method is quite fast, and can produce a much better impression in most
  1271. cases.  The keyword nointerpolate does the opposite.
  1272.  
  1273. The default is no interpolation.
  1274.  
  1275.  
  1276.  
  1277. 4.4.12  Turbulence
  1278.  
  1279. The turbulence keyword can be added to any texture, and it will make the
  1280. pattern or image (if any) of the texture 'distorted'.  After the turbulence
  1281. keyword you must specify a decimal value specifying the turbulence
  1282. intensity.  The value may range from zero to "infinity", where zero means
  1283. no turbulence.  However, 0.0 to 1.0 is a more reasonable range, where 1.0
  1284. makes the texture very turbulent.  Often values like 0.1-0.4 are enough.
  1285. Try experimenting with turbulence on different textures; it is really
  1286. powerfull (ever seen a turbulent mandelbrot set before?).  It should be
  1287. mentioned that turbulence is quite CPU consuming.
  1288.  
  1289. The default turbulence intensity is 0 (no turbulence).
  1290.  
  1291.  
  1292.  
  1293. 4.4.13  Default
  1294.  
  1295. The keyword default can be placed in a texture section to initialize the
  1296. texture with RayLabs hardcoded default settings.  The default setting for
  1297. each component is given in the corresponding section in this document (e.g.
  1298. the color in section 4.4.1).
  1299.  
  1300.  
  1301.  
  1302. 4.5 Deftexture
  1303. --------------
  1304.  
  1305. With a deftexture section, you can specify a default texture that will be
  1306. applied to all the following objects in the scene description (it does,
  1307. however, not affect the 'default' keyword described in section 4.4.13).
  1308. Example:
  1309.  
  1310. Deftexture:
  1311.         reflect  0.6 0.6 0.6
  1312.         pattern  spots
  1313.         colormap 4
  1314.                 0.0  1 0 0
  1315.                 0.7  1 0 0
  1316.                 0.8  0.2 0.2 0.2
  1317.                 1.0  0 0 0
  1318. :end
  1319.  
  1320. At the end of the list of all objects that are to have the texture
  1321. specified by deftexture, you will probably want to reinitialize the
  1322. hardcoded default texture.  Simply write:
  1323.  
  1324. Deftexture:
  1325.         default
  1326. :end
  1327.  
  1328.  
  1329.  
  1330. 4.6 Transform
  1331. -------------
  1332.  
  1333. When the shape of a primitve is too limited for your demands, chances are
  1334. that the transformation facilities of RayLab can help you.  Transformations
  1335. can change the shape, location and orientation of any primitive or texture.
  1336. There are currently three transformations available in RayLab that apply to
  1337. both objects and textures:  scale, move and rotate.  For textures, you may
  1338. also use:  whirl and twist.  A transform section can contain a maximum of
  1339. ten transformations, which are applied to the object or texture in the
  1340. order they are entered in the description.  A transform section is started
  1341. with the transform keyword, and ended with :end.
  1342.  
  1343. To transform an object, the transform section should be placed somewhere
  1344. before the end of the object.  If the transformation is placed after the
  1345. texture-declaration (if any), the texture too is transformed, but if it is
  1346. placed before the texture section, the texture is not transformed.  You can
  1347. also place a transform section inside a texture section, which will only
  1348. affect the texture.  Image-textures can also be transformed (please refer
  1349. to the section that describes how to use image-textures for more infor-
  1350. mation).
  1351.  
  1352. Here is an example of a transform section:
  1353.  
  1354.     transform:
  1355.         rotate 30 0 0          # rotate 30 degrees around the x-axis
  1356.         scale  3 0.6 1         # scale 3*x, 0.6*y and 1*z
  1357.         move   -3 0 4          # move the object -3*x +4*z from its current
  1358.     :end                       #  location
  1359.  
  1360. Note that the following example will NOT do the same thing as the above:
  1361.  
  1362.     transform:
  1363.         move   -3 0 4
  1364.         rotate 30 0 0
  1365.         scale  3 0.6 1
  1366.     :end
  1367.  
  1368. All transformations that can be done to an object, can also be done to a
  1369. texture or an image, independently.  On the other hand, some special
  1370. transformations that are valid for textures and images, do not work with
  1371. objects.
  1372.  
  1373. Often you may want to change the size or orientation of a pattern.  To
  1374. transform a texture, add a transform section inside the texture section.
  1375. This example shows how you can make a pattern twice as large as its
  1376. original size:
  1377.  
  1378.     texture:
  1379.         ...
  1380.         transform:
  1381.                 scale 2 2 2
  1382.         :end
  1383.     :end
  1384.  
  1385.  
  1386.  
  1387. 4.6.1  Scale
  1388.  
  1389. Scaling an object means stretching or shrinking it along the x, y and z
  1390. axes respectively.  A scale value of 1.0 means no change.  A value larger
  1391. than 1.0 means enlarging and a value less than 1.0 means shrinking (the
  1392. scaling value must be larger than 0.0).  One value must be given for each
  1393. direction:  x, y, z (i.e.  three decimal values must follow the scale
  1394. keyword).  The scaling is always done relative to (0,0,0) in space, so if
  1395. you scale a primitive that has an origin different from (0,0,0), it will
  1396. also be moved.
  1397.  
  1398.  
  1399.  
  1400. 4.6.2  Move
  1401.  
  1402. Moving an object means moving it from its current location to a location
  1403. given by (current location) + (movement).  Also here three decimal values
  1404. must be given after the keyword.
  1405.  
  1406.  
  1407.  
  1408. 4.6.3  Rotate
  1409.  
  1410. After the rotate keyword you must specify three angles (in degrees).  They
  1411. represent the rotation around each of the x, y and z axes, and the rotation
  1412. is performed in that order (first x, then y and last z).  To find out which
  1413. way is the positive rotation, try this trick:  hold up your right hand in
  1414. front of you, extend your thumb and curl the other fingers.  Now, if you
  1415. place your hand so that the thumb points in the positive direction of the
  1416. axis that you want to rotate about, the four other fingers will show the
  1417. positive direction of rotation (believe me, I do this all the time).
  1418. Remember that RayLab uses a right hand system, so the orientation of the
  1419. axes is as follows:  the x-axis points right, the y-axis points "away"
  1420. (into the screen), and the z-axis points up.  An object or a texture is
  1421. always rotated around (0,0,0) in space, so if you rotate a primitive that
  1422. has an origin different from (0,0,0), it will also be moved.
  1423.  
  1424.  
  1425.  
  1426. 4.6.4  Whirl
  1427.  
  1428. The whirl transformation may only be used for textures or images.  It
  1429. creates a whirl with its centre in (0,0,0), which 'rotates' in the positive
  1430. direction around the z-axis.  With the keyword whirl you must specify the
  1431. radius of the whirl, and its intensity, in that order.  If the intensity is
  1432. negative, the whirl rotates in the negative direction around the z-axis.
  1433. Here is an example of a 'whirly' texture:
  1434.  
  1435.     texture:
  1436.         ...
  1437.         transform:
  1438.             whirl   2.5  0.3    # radius = 2.5, intensity = 0.3
  1439.         :end
  1440.     :end
  1441.  
  1442.  
  1443.  
  1444. 4.6.5  Twist
  1445.  
  1446. The twist transformation may only be used for textures or images.  It will
  1447. twist the texture around the z-axis.  After the twist keyword, you must
  1448. enter a decimal number which indicates the z-height of 'one twist' (a full
  1449. turn, 360°).
  1450.  
  1451.  
  1452.  
  1453. 4.6.6  None
  1454.  
  1455. The keyword none will clear a whole transform sequence.
  1456.  
  1457. The default transformation is no transformation.
  1458.  
  1459.  
  1460.  
  1461. 4.7 Deftransform
  1462. ----------------
  1463.  
  1464. With a deftransform section, you can specify a default transformation
  1465. sequence that will be applied to all the following objects and textures in
  1466. the scene description.  Example:
  1467.  
  1468. Deftransform:
  1469.         rotate 30 -45 17
  1470.         move   10 0 -5
  1471. :end
  1472.  
  1473. At the end of the list of all objects that are to be transformed with a
  1474. deftransform, you need to withdraw the deftransform.  Simply write:
  1475.  
  1476. Deftransform:
  1477.     none
  1478. :end
  1479.  
  1480. NOTE:  I have found little use for the deftransform function.  It is better
  1481. replaced by combining several objects into a CSG section, and then trans-
  1482. forming the entire CSG (which is also faster, as only one transformation is
  1483. needed, instead of one for each object).  The deftransform was, however,
  1484. necessary in RayLab 1.0, as CSG was not implemented then.
  1485.  
  1486.  
  1487.  
  1488. 4.8  Bounding volumes
  1489. ---------------------
  1490.  
  1491. A ray-tracer spends most of its time on finding out whether a ray hits an
  1492. object or not.  The more objects in a scene, the more testing is needed.
  1493. To reduce the work that is needed for this task, there are several
  1494. techniques.  One of the oldest and simplest is to 'surround' one shape with
  1495. another shape that is easier to test against (it is called bounding one
  1496. shape with another one).  Before an intersection-test with the 'real' shape
  1497. is done, an intersection is tested with the bounding volume.  If the
  1498. bounding volume was hit, the bounded shape is tested, otherwise it is not.
  1499. The bounding shape will not be visible, but it must surround the visible
  1500. shape fully.
  1501.  
  1502. RayLab supports two very optimized shapes:  box and sphere.  Two special
  1503. intersection routines have been written for those shapes to be used as
  1504. bounding volumes, and they are very fast.
  1505.  
  1506.  
  1507.  
  1508. 4.8.1  How to use bounding volumes in RayLab
  1509.  
  1510. To bound one object (all objects, including CSG's, may be bounded), add a
  1511. bounding section before the end of the object.  A bounding section is
  1512. started with the keyword bounding, and followed by the bounding shape (box:
  1513. or sphere:).  Example:
  1514.  
  1515. Cylinder:
  1516.         start -3 2 1
  1517.         end   3 2 1
  1518.         radius 1
  1519.         bounding box:
  1520.                 corners  -3 1 0
  1521.                           3 3 2
  1522.         :end
  1523. :end
  1524.  
  1525. The bounding shape may not contain anything but the shape-specific infor-
  1526. mation (e.g.  it may not have any texture or transformation specification).
  1527. Bounding volumes are affected by transformations that come after the
  1528. bounding declaration, but not by transformations that come before. Although
  1529. not transformed, the bounding volume is modified to make sure that it
  1530. corresponds to the transformed shape.
  1531.  
  1532.  
  1533.  
  1534. 4.8.2  When to use bounding volumes
  1535.  
  1536. First of all, bounding volumes are only used for speedup reasons.  Do not
  1537. use bounding volumes to clip away parts of an object (try to use the CSG
  1538. facilities of RayLab for that instead), as it will most likely not give the
  1539. results that you expect.
  1540.  
  1541. Bounding volumes are most efficient under these two conditions:
  1542.  
  1543.  - When an object is very complex, such as a CSG object.
  1544.  - When an object does not occupy huge portions of the rendered image; it
  1545.    does not make much sense to bound an object that is hit by almost every
  1546.    ray.
  1547.  
  1548. If a shape is easily bounded (approximated) with a box or a sphere, it is
  1549. possible that you may find speedups even by bounding simple shapes,
  1550. especially if they are transformed.
  1551.  
  1552.  
  1553.  
  1554. 4.9  Miscellaneous object modifiers
  1555. -----------------------------------
  1556.  
  1557.  
  1558. 4.9.1  Noshadow and shadow
  1559.  
  1560. Sometimes you do not want an object to cast shadows.  For instance, if you
  1561. want to give a shape to a light-source, you would typically surround the
  1562. light-source with an object, such as a white sphere, but then that object
  1563. would cover the light-source totally, letting no light through.  Adding the
  1564. keyowrd noshadow to the object declaration will make it cast no shadows.
  1565. The opposite keyword, shadow, will make an object cast shadows, which is
  1566. the default.  Here is an example:
  1567.  
  1568. Sphere:
  1569.         centre -3 4 7
  1570.         radius 0.5
  1571.         texture:
  1572.                 color 1 1 1
  1573.         :end
  1574.         noshadow                # This sphere will not cast any shadows
  1575. :end
  1576.  
  1577. If you add a noshadow/shadow keyword to a CSG-section, all objects that are
  1578. part of the CSG will be given the corresponding noshadow/shadow property.
  1579. If any noshadow/shadow keyword is entered in an individual object of the
  1580. CSG-section, it will be over-ridden by the keyword for the whole CSG.
  1581.  
  1582.  
  1583.  
  1584. 4.10  Lights
  1585. ------------
  1586.  
  1587. Every scene needs at least one light-source.  Light-sources in RayLab are
  1588. s.c.  point lights, which means that they cast their light in all
  1589. directions, and they are infinitely small (you can not see them if you turn
  1590. your camera to look at them).  Light-sources can have different colors, and
  1591. thereby also different intensities (a grey light-source does not give as
  1592. much light as a white light-source does).  A normal light-source is simply
  1593. defined by a location and a color.
  1594.  
  1595.  
  1596.  
  1597. 4.10.1  Location
  1598.  
  1599. With the keyword location you specify where the light-source should be in
  1600. space.
  1601.  
  1602. The default location is (10,-10,10).
  1603.  
  1604.  
  1605.  
  1606. 4.10.2  Color
  1607.  
  1608. The keyword color specifies what color and intensity a light-source should
  1609. have.
  1610.  
  1611. The default color is (1.0 1.0 1.0), which is 100% white.
  1612.  
  1613.  
  1614.  
  1615. 4.10.3  Soft light-sources
  1616.  
  1617. One problem with the basic ray-tracing technique is that the edges of
  1618. shadows become very sharp.  This is because the light-sources are
  1619. infinitely small.  To produce softer shadows you need a light model where
  1620. the light-sources have a size.  RayLab 1.1 implements a very un-optimized
  1621. light-model to produce soft shadows.  To control soft light-sources, you
  1622. use the keywords size, softness and jitter.  Be warned though:  soft
  1623. light-sources are extremely slow in RayLab 1.1, but I hope that I can use
  1624. the same syntax for a more optimized model in the future.
  1625.  
  1626.  
  1627. 4.10.3.1  size
  1628.  
  1629. The size keyword indicates the 'diameter' of the light-source.
  1630.  
  1631. The default size is 0.5.
  1632.  
  1633.  
  1634. 4.10.3.2  softness
  1635.  
  1636. With softness, you specify how many rays will be used to approximate the
  1637. soft shadow.  The amount of rays can be calculated as the square of
  1638. (softness+1), e.g.  softness 1 means four rays, softness 2 means nine rays
  1639. etc.
  1640.  
  1641. The default softness is 0, which means no softness at all.
  1642.  
  1643.  
  1644. 4.10.3.3  jitter
  1645.  
  1646. To improve the appearance of the shadows, some jittering can be added to
  1647. the ray-directions.  The jittering can range from 0.0 (no jittering) to 1.0
  1648. (full jittering).
  1649.  
  1650. The default jittering is 0.1.
  1651.  
  1652.  
  1653.  
  1654. 4.11  Camera
  1655. ------------
  1656.  
  1657. The camera is indeed a very important part of the scene.  The camera does
  1658. not have a shape, and will not be seen through a mirror or alike.  To
  1659. specify the properties of the camera, the keywords location, viewpoint and
  1660. aspect can be used.
  1661.  
  1662.  
  1663.  
  1664. 4.11.1  Location
  1665.  
  1666. The camera can be placed anywhere in space.  This is given by the keyword
  1667. location.
  1668.  
  1669. The default location is (0,-10,1).
  1670.  
  1671.  
  1672.  
  1673. 4.11.2  Viewpoint
  1674.  
  1675. When the camera has been placed, it also needs to be directed to look at
  1676. some point in space.  In RayLab you only have to tell where to look at with
  1677. the keyword viewpoint.  The direction of the camera will be calculated
  1678. automatically.
  1679.  
  1680. The default viewpoint is (0,0,0).
  1681.  
  1682.  
  1683.  
  1684. 4.11.3  Aspect
  1685.  
  1686. The camera is also defined by its x:y:z aspect, which enables you to set
  1687. the pixel-aspect of the output picture and the field of view of the camera.
  1688. The x:y aspect should be the same as that of the output picture.  E.g.  a
  1689. 640x480 picture has the aspect 4:3 if the pixels are to be completely
  1690. square.  In general, you should use the same xy aspect as that of the
  1691. display (regardless of the amount of pixels in each direction).  The aspect
  1692. ratio does not have to be integer values in RayLab.  The z-aspect is the
  1693. 'depth' of the lens, and it is also proporional to the x and y aspect.
  1694. With the z aspect you may change the field of view.  This figure may be of
  1695. some help (I did my best in this ascii version!):
  1696.  
  1697.  
  1698.                                    |\_
  1699.                                    |  \_ X
  1700.                                    |    \_
  1701.                                    |      \_   Projection
  1702.                                    |        \
  1703.                   Camera           |         |   window
  1704.                          ()------------->    |
  1705.                  location      Z   |         |
  1706.                                     \_       | Y
  1707.                                       \_     |
  1708.                                         \_   |
  1709.                                           \_ |
  1710.                                             \|
  1711.  
  1712.  
  1713.  
  1714. Larger values of the z aspect will give more tele-zoom, and smaller values
  1715. will give wide-angle views.
  1716.  
  1717. Here is an example of a camera with extreme tele-zoom:
  1718.  
  1719. Camera:
  1720.         location   0 -100 30    # We have to back off a bit due
  1721.         viewpoint  0 0 0        # to the zooming
  1722.         aspect     4 3 20
  1723. :end    
  1724.  
  1725. The default aspect is 4:3:5, which gives quite a normal angle of view.
  1726.  
  1727.  
  1728.  
  1729. 4.12  Globals
  1730. -------------
  1731.  
  1732. In RayLab some interesting and useful parameters can be setup in a section
  1733. called globals.  Most of these parameters may be setup from the command
  1734. line, which will override parameters written in a globals section.
  1735.  
  1736.  
  1737.  
  1738. 4.12.1  Picwidth
  1739.  
  1740. The keyword picwidth is followed by an integer value telling RayLab how
  1741. many columns the output picture will have.  For a 640x480 image this would
  1742. be 640.
  1743.  
  1744. The default picture width is 200.  The command line equivalent is
  1745. -w<picwidth>.
  1746.  
  1747.  
  1748.  
  1749. 4.12.2  Picheight
  1750.  
  1751. Picheight specifies the amount of lines that the output image will consist
  1752. of.
  1753.  
  1754. The default picture height is 150.  The command line equivalent is
  1755. -h<picheight>.
  1756.  
  1757.  
  1758.  
  1759. 4.12.3  Format
  1760.  
  1761. With the keyword format, you may specify the output file format.  The
  1762. currently supported formats are:  iff (24-bit compressed IFF ILBM), tga
  1763. (24-bit uncompressed Targa), ppm (24-bit PPM) and none (no output image is
  1764. produced).  Example:
  1765.  
  1766.         format ppm              # Use PPM image output
  1767.  
  1768. The default format is iff. The command line equivalent is -f<format>.
  1769.  
  1770.  
  1771.  
  1772. 4.12.4  Recdepth
  1773.  
  1774. The keyword recdepth is used to specify how many recursions RayLab is
  1775. allowed to do for each camera-ray.  A recursion-depth of 2 means that a ray
  1776. will only 'bounce' one time through reflection and/or transparency, and a
  1777. recursion-depth of 1 results in no reflection/transparency at all.  Higher
  1778. values mean more realistic pictures if there are many reflective or
  1779. transparent surfaces in the scene, but also longer rendering-times.  For a
  1780. fast preview, you could specify a recdepth of 1:
  1781.  
  1782.         recdepth 1
  1783.  
  1784. The default recursion depth is 10.  The command line equivalent is
  1785. -r<recdepth>.
  1786.  
  1787.  
  1788.  
  1789. 4.12.5  Display
  1790.  
  1791. If you want to view a picture as it is being rendered, add the keyword
  1792. display to your globals section.  Following the keyword you must specify a
  1793. display type.  The display types are machine specific, so please consult
  1794. the documentation for your specific platform for more information.  The
  1795. display type is an integer value.  Example:
  1796.  
  1797.         display 1
  1798.  
  1799. Zero (0) means no display, which is the default setting.  The command line
  1800. equivalent is -d<displaytype>.
  1801.  
  1802.  
  1803.  
  1804. 4.12.6  Antialiasrec
  1805.  
  1806. This keyword turns on anti-aliasing, which can greatly improve the appear-
  1807. ance of a scene.  You must specify the recursion depth of the anti-
  1808. aliasing, which is done with an integer value placed after the keyword.
  1809. Example:
  1810.  
  1811.         antialiasrec 3
  1812.  
  1813. Zero (0) means no anti-aliasing, which is the default.  The command line
  1814. equivalent is -ar<antialiasrec>.
  1815.  
  1816. The recursion level can range from 0 (no anti-aliasing) to 4 (extremely
  1817. heavy anti-aliasing).  A value of 2 or 3 should be enought in most cases.
  1818. Never use a recursion level of 1 though, as it is totally useless (it just
  1819. blurs the picture, even turning anti-aliasing off looks better).  For the
  1820. different recursion levels, this is the maximum amount of rays that are
  1821. traced for each pixel:
  1822.  
  1823.         Level:  Rays:
  1824.             0      1
  1825.             1      4
  1826.             2      9
  1827.             3     25
  1828.             4     81
  1829.  
  1830. Well, RayLab uses a very intelligent adaptive method (meaning it does not
  1831. have to trace more rays than really necessary), so in reality only one to
  1832. six rays have to be traced per pixel if there are not too many edges and
  1833. contours in the picture.
  1834.  
  1835.  
  1836.  
  1837. 4.12.7  Antialiasthreshold
  1838.  
  1839. As mentioned, RayLab uses an adaptive method for anti-aliasing.  This is
  1840. achived by comparing the colors from the four corners of a square (this
  1841. square is in reality a pixel from the picture).  If the difference between
  1842. the colors is not too big, it is assumed that this entire square has the
  1843. same color (which is the average of the four colors).  If the difference
  1844. exceeds a certain value, the first square is divided into four new squares,
  1845. which are checked in the same manner.  With antialiasthreshold you can
  1846. specify the threshold for how big the difference between the colors may be
  1847. before another recursion takes place.  The value specified after the
  1848. keyword must be a decimal value ranging from 0.0 (all rays are cast as
  1849. specified by the anti-aliasing recursion level) to 3.0 (no squares are
  1850. subdivided).  Example:
  1851.  
  1852.         antialiasthreshold 0.4
  1853.  
  1854. The color difference is calculated as the sum of the maximum red, green and
  1855. blue differences.  The default value is 0.3, which seems to be a very good
  1856. value.  In some cases I have seen the need for stepping down to 0.2.  The
  1857. command line equivalent is -at<antialiasthreshold>.
  1858.  
  1859.  
  1860.  
  1861. 4.12.8  Antialiasjitter
  1862.  
  1863. When the above mentioned anti-aliasing method is used, you may still be
  1864. able to distinguish certain 'patterns' at sharp edges of objects and
  1865. textures.  To help prevent this, some jittering of the ray-directions may
  1866. be added.  This is done with the keyword antialiasjitter, which takes a
  1867. value between 0.0 (no jittering) and 1.0 (very much jittering).
  1868.  
  1869. The default value is 0.05.  The command line equivalent is
  1870. -aj<antialiastjitter>.
  1871.  
  1872.  
  1873.  
  1874. 4.12.9  Quickscan
  1875.  
  1876. Sometimes you just want to see how the objects in a scene are placed, and
  1877. how the camera is set.  Then the quickscan alternative is very useful.
  1878. With quickscan activated, many of RayLabs features are disabled; no
  1879. reflection or transparency is produced, most texture features are lost
  1880. (such as patterns, images, highlights, diffuse and ambient) and no shadows
  1881. are produced.  All light-sources are skipped, and the light is considered
  1882. to come from the point of the observer.  As a result of all this, the
  1883. rendering of a picture is faster than usual, much faster in many cases.
  1884.  
  1885. To activate the quickscan rendering method, add the keyword quickscan to a
  1886. globals section.  Anti-aliasing settings have no effect when quickscan is
  1887. activated.
  1888.  
  1889. The default is no quickscan. The command line equivalent is -q.
  1890.  
  1891.  
  1892.  
  1893. 4.12.10  Trace
  1894.  
  1895. Trace is just the opposite to quickscan.  With the keyword trace you
  1896. specify that you want all ray-tracing features of RayLab enabeled (such as
  1897. transparency, reflection, highlights, shadows and texture patterns), which
  1898. is the default.
  1899.  
  1900. The command line equivalent is -t.
  1901.  
  1902.  
  1903.  
  1904. 4.12.11  Backgroundcolor
  1905.  
  1906. You can specify a color that will be the background color of your scene.
  1907. For instance this can be very useful if you make an outdoor scene where you
  1908. want the sky to be blue; simply set the background color to blue.
  1909. Backgroundcolor is followed by three decimal values ranging from 0.0 (0%)
  1910. to 1.0 (100%), each value representing the red, green and blue components
  1911. of the color, respectively, in that order.  Example:
  1912.  
  1913.         backgroundcolor 0.3 0.0 0.0     # Dark red sky
  1914.  
  1915. The default background color is 0 0 0 (black).  Backgroundcolor has no
  1916. command line equivalent.
  1917.  
  1918.  
  1919.  
  1920. 4.12.12  Fogdistance
  1921.  
  1922. An effect which does not require much rendering-time, but yet can produce
  1923. very interesting results, is the global fog.  By enabeling fog, the further
  1924. away objects are, the less visible they are, and the more intense the fog
  1925. is.  With the keyword fogdistance, you specify the distance at which the
  1926. fog-intensity is 63%.  That number is derived from the formula that is used
  1927. to calculate the fog-intensity:
  1928.  
  1929.                 fogintensity = 1 - exp(-distance/fogdistance)
  1930.  
  1931. Thus you can see, that at infinity the fog-intensity is 100%, and at
  1932. zero-distance, the intensity is 0%.  Example of fogdistance usage:
  1933.  
  1934.         fogdistance 20
  1935.  
  1936. By specifying a fog-distance of less than or equal to zero, you disable
  1937. fog.
  1938.  
  1939. The default is no fog. Fogdistance has no command line equivalent.
  1940.  
  1941.  
  1942.  
  1943. 4.12.13  Fogcolor
  1944.  
  1945. To specify the color of the fog, use the keyword fogcolor. Example:
  1946.  
  1947.         fogcolor 0.9 0.8 1.0    # Bright, slightly blue/purple fog
  1948.  
  1949. Apart from the normal grey/white fogs, you can use black fog for a nice
  1950. fade-away effect, or blue fog for an under-water effect.  Or how about some
  1951. extreme applications?  I used a bright yellow fog in a scene where the
  1952. camera was placed inside a tunnel, which made it look like a bright light
  1953. at the end of the tunnel, very cool!
  1954.  
  1955. The default fog color is 0.8 0.8 0.8 (light grey).  Fogcolor has no command
  1956. line equivalent.
  1957.  
  1958.  
  1959.  
  1960. 4.13  Comments
  1961. --------------
  1962.  
  1963. In RayLab scene descritions you can put comments to clarify your work, both
  1964. to yourself and others.  A comment can be placed anywhere, except in the
  1965. middle of or right after (no space, tab or newline between) a keyword or a
  1966. number.  Every comment is started by a comment identifyer and it is ended
  1967. at the end of the line.  Valid comment identifiers are # ; and *
  1968.  
  1969. Example:
  1970.  
  1971. Sphere:                 # This is a sphere
  1972.         centre  0 0 0   ; and it is placed in (0,0,0)
  1973.         radius          ****** ok, here comes the radius:
  1974.         2
  1975. :end
  1976.  
  1977. As you see, it is fully possible to put a comment between the keyword and
  1978. its parameter(s), although it does not look very nice in this example.
  1979.  
  1980.  
  1981.  
  1982.  
  1983.                              5.  MISCELLANEOUS
  1984.                              =================
  1985.  
  1986.  
  1987.  
  1988. 5.1  How to contact the author
  1989. ------------------------------
  1990.  
  1991. I always like to get response from people who somehow come across my work,
  1992. be it good or be it bad.  So if you have used RayLab, read the documen-
  1993. tation or heard about my latest assembler program for the C=64, please drop
  1994. a mail in my e-box:
  1995.  
  1996.   internet:     e4geeln@etek.chalmers.se
  1997.  
  1998. To check out the latest news about RayLab and to get the latest version for
  1999. any supported platform, you can go to The RayLab Home Page on the world
  2000. wide web:
  2001.  
  2002.   WWW:          http://www.etek.chalmers.se/~e4geeln/raylab/
  2003.  
  2004. If you get any error-messages when compiling RayLab on your system, please
  2005. let me know as it would be nice to have it compile flawlessly on as many
  2006. systems as possible.  Do not hesitate to report things like "strings.h not
  2007. found..." (it worked fine on my Amiga and at the university, but not at a
  2008. friends PC with an old Microsoft compiler.  Now I know it should be
  2009. string.h!!).
  2010.  
  2011. Any bug-reports etc.  will of course be warmly welcomed.  If you do not
  2012. have access to internet, you can contact me by snail-mail:
  2013.  
  2014.   s-mail:       Marcus Geelnard
  2015.                 Utbynasgatan 11
  2016.                 S-415 06 Goteborg
  2017.                 Sweden
  2018.  
  2019.  
  2020.  
  2021. 5.2  Legal stuff
  2022. ----------------
  2023.  
  2024. Here is what you should know about what you can do, and what you can not:
  2025.  
  2026. o RayLab is provided as is, and the author can not be held responsible for
  2027.   any system or hardware failure or data loss as a result, direct or in-
  2028.   direct, of the use of RayLab. Use RayLab at your own risk.
  2029.  
  2030. o RayLab is totally free! You should not pay a penny for the actual soft-
  2031.   ware, nor can anybody claim any money for RayLab (except for formal fees
  2032.   for storage media or transfer costs). You may not sell RayLab for money
  2033.   or in any other way charge money for any part(s) of the RayLab package.
  2034.  
  2035. o You may NOT change RayLab in part or in whole, and then redistribute it!
  2036.   The files and the contents of the files must remain as is, and they must
  2037.   all be there with their original names and in their original directory
  2038.   structures!
  2039.  
  2040. o You may NOT use any part(s) of the RayLab sourcecode for your own produc-
  2041.   tions, neither commercial nor noncommercial!
  2042.  
  2043. o If you want to use RayLab or any pictures that are produced with RayLab
  2044.   for commercial purposes, you will have to get the permission to do so
  2045.   from the author of RayLab.
  2046.  
  2047. o For noncommercial use of RayLab, such as a private art-gallery, you need
  2048.   no permission from the author of RayLab.
  2049.  
  2050. o You may NOT spread your own compilation of RayLab without permission from
  2051.   the author of RayLab!
  2052.  
  2053. If anything is uncertain, or if you feel like breaking any of the above
  2054. stated rules, e.g.  if you want to improve RayLab, try contacting me (the
  2055. author of RayLab) first.  I am not unreasonable, but I do like to have some
  2056. control of my own software.
  2057.  
  2058.  
  2059.  
  2060. 5.3  Past, present and the future
  2061. ---------------------------------
  2062.  
  2063. Since the previous release of RayLab (1.0 rev 1), these changes/additions
  2064. have been made:
  2065.  
  2066. o  Transparency with refraction was added (at last).
  2067. o  Constructive solid geometry (CSG) was added.
  2068. o  Added compressed 24-bit IFF and 24-bit PPM image output.
  2069. o  Added new patterns: marble (thanks to Tobias Mellqvist), squares,
  2070.    mandel, wood, blurb and angular.
  2071. o  Texture turbulence was added.
  2072. o  Added new transformations for textures: whirl and twist.
  2073. o  Improved 'safe termination', which among other things means that you can
  2074.    view an image correctly that was only partly rendered before a CTRL-C.
  2075. o  The cone primitive was added.
  2076. o  The cylinder primitive was improved.
  2077. o  Speedup with bounding volumes was implemented.
  2078. o  The 'noshadow' option was added.
  2079. o  Improved anti-aliasing with 'antialiasjitter' (and removed an old bug
  2080.    that limited the anti-aliasing recursion level to level three, which
  2081.    should have been four).
  2082. o  The parsing routines have been improved a great deal, which means better
  2083.    handling of bad description files and less redundancy in the code.
  2084. o  New display-modes were added for the Amiga, HAM8 in particular.
  2085. o  A primitive model for soft shadows was introduced.
  2086. o  The quick-scan rendering method was added for faster previews.
  2087. o  Large portions of the program code was rearranged and improved, mostly
  2088.    due to the introduction of CSG.
  2089.  
  2090.  
  2091. Things that I would like to implement in RayLab, but I don't know when, or
  2092. even if, it will be (it's a question of time and priority):
  2093.  
  2094. o  Speeeedups! Main ideas that are rushing around in my head are: octree-
  2095.    optimization and light-buffers.
  2096. o  Support for variable declarations in scene descriptions.
  2097. o  Animation support, which will consist of a good expression handler and
  2098.    some useful mathematical functions like sin(x), sqrt(x), log(x) etc.
  2099. o  Better (=faster) soft light-sources, and more light models (like spot-
  2100.    lights).
  2101. o  Surface normal modifiers, like bumpiness and waves.
  2102. o  Even more patterns, and multiple weighted textures.
  2103. o  Depth of field.
  2104. o  Motion blur (based on the animation support, don't know how though?).
  2105. o  Some other fun things that may pop up, like fish-eye camera-projection.
  2106. o  ......more, more, more, drewl, pant, more!....
  2107.  
  2108. Any further suggestions are of course welcome...
  2109.  
  2110.  
  2111.  
  2112. 5.4  Acknowledgements
  2113. ---------------------
  2114.  
  2115. I would like to thank many people, but the following people in particular,
  2116. for their help and support:
  2117.  
  2118. o  Brian Jones, for his dedication and his patient beta-testing of RayLab.
  2119.  
  2120. o  Tobias Mellqvist, for feeding me with information and ideas.
  2121.  
  2122. o  Andreas Magnusson, for his work on (the not yet finished) numerical
  2123.    methods of root-solving.
  2124.  
  2125. o  Jean-Baptiste Novoit, for his help with documentation and for compiling
  2126.    RayLab for Linux and the BeBox.
  2127.  
  2128.  
  2129.  
  2130. 5.5  Compability
  2131. ----------------
  2132.  
  2133. When RayLab was designed, compability between platforms was a high-prioroty
  2134. issue, and it still is.  The major reason at first was that I use an Amiga
  2135. 3000 at home, where most of the development has been done, but I use
  2136. DEC-Alpha stations at the university (Chalmers university of technology),
  2137. which are very fast, and thus very attractive for ray-tracing.  So my goal
  2138. was to be able to compile RayLab on both the Amiga platform and on the Unix
  2139. platform.
  2140.  
  2141. A 'side-effect' of this is that it is possible to compile RayLab on almost
  2142. any platform whitout any major changes/additions to the code (the system
  2143. should be at least 32-bit though, like the Amiga 500).  And for RayLab to
  2144. gain users, it is a good thing that it can be used on many platforms,
  2145. of course.  I have compiled RayLab for these systems with success:
  2146.  
  2147.  - Amiga, compiled with gcc 2.7.0 and Sas/C
  2148.  
  2149.  - DEC-Alpha (OSF/1), compiled with gcc and cc
  2150.  
  2151.  - HP-UX, compiled with cc
  2152.  
  2153.  - 486-PC (no FPU) running OS/2, compiled with gcc 2.7.2
  2154.  
  2155.  - Pentium-PC running DOS/Win 3.1, compiled with gcc 2.7.2
  2156.  
  2157. Worth noting is that the DEC-Alpha is a 64-bit system, which many programs
  2158. have problems to cope with.  In the RayLab code, no special assumptions
  2159. about the sizes or formats of different variable-types are made.  E.g.
  2160. long int may be 32-bit, 64-bit, 48-bit, 256-bit or whatever, and no strange
  2161. casting between different types are made (such as turning a (void *) into a
  2162. (long int)).  The only real requirement is that long int is at least 32
  2163. bits wide.
  2164.  
  2165.  
  2166.  
  2167. 5.6  Comments by the author
  2168. ---------------------------
  2169.  
  2170. I admit that RayLab was influenced by other raytracers that I have used
  2171. (POV-Ray, Imagine, Rayshade etc.), but that is mostly due to my finding
  2172. parts of those raytracers very natural.  I did, however, start from scratch
  2173. when I developed RayLab.  I have not used or hardly even looked at
  2174. sourcecode from other raytracers during the development of RayLab, so
  2175. RayLab is based upon my own assumptions about how things work.  One day I
  2176. came across a book called 'Fundamentals of Three-Dimensional Computer
  2177. Graphics' by Alan Watt.  It was fun to see that what I had done was actu-
  2178. ally identical to what was described in that book, like how the general
  2179. Phong shading model works.
  2180.  
  2181. There are some undocumented features of RayLab, which you will see if you
  2182. study the source code, that I have chosen not to mention as they either do
  2183. not work properly (yet) or are redundant.  For instance you can specify the
  2184. quickscan rendering method by adding the keyword 'quickscan' to a globals
  2185. section, according to the documentation.  You may also write 'rendermethod
  2186. quickscan' or 'rendermethod quick'.
  2187.  
  2188. Pheew!  This documentation, AND RayLab as a whole, got a bit larger than
  2189. expected...  This program was intended to be a simple personal hack, not a
  2190. commercial raytracer (don't worry:  RayLab will be freeware as long as I
  2191. can keep it that way)!
  2192.  
  2193.